var urlJson = '';
$(function () {
    var repairCode = getQueryString('repairCode')
    if (repairCode) {
        vm.q.repairCode = 'REP-' + repairCode
    }
    var queryUrl = '../devmaintenwork/list';
    var id = getQueryString('Id');
    if (id) {
        queryUrl += '?id=' + id;
    }
    $("#jqGrid").Grid({
        url: queryUrl,
        colModel: [
            {label: '报修编号', name: 'shortRepairCode', index: 'REPAIR_CODE', width: 75},
            {label: '设备名称', name: 'devName', index: 'DEV_NAME', width: 130},
            {label: '设备编码', name: 'devCode', index: 'DEV_CODE', width: 75},
            {
                label: '来源', name: 'source', index: 'SOURCE', width: 50,
                formatter: function (value, col, row) {
                    return sysEnums.TICKET_SOURCE[value];
                }
            },
            {label: '维修开始时间', name: 'startRepairTime', index: 'START_REPAIR_TIME', width: 100},
            {label: '报警信息',sortable: false,
                formatter: function (value, col, row) {
                    if(row.faultCode && row.faultDesc){
                        return row.faultCode + ' ' + row.faultDesc;
                    }else{
                        return '未设置';
                    }
                }
            },
            {label: '维修人员', name: 'repairUserName', index: 'DMW.REPAIR_USER', width: 60},
            {
                label: '维修时长',
                name: 'repairDuration',
                index: '(DMW.END_REPAIR_TIME - DMW.START_REPAIR_TIME)',
                width: 45
            },
            {
                label: '工单状态', width: 60, index: 'DEV_STATUS',
                formatter: function (value, col, row) {
                    return sysEnums.REPAIR_TICKET_STATUS[row.devStatus];
                }, frozen: true
            },
            {
                label: '记录信息', name: 'records', sortable: false, cellattr: function (value, col, row) {
                    return "style='color:red'";
                }
            },
            {name: 'id', key: true, hidden: true},
            {name: 'urgeStatus', hidden: true},
            {name: 'devId', index: 'DEV_ID', hidden: true},
            {name: 'devStatus', hidden: true},
            {name: 'workshopId', hidden: true},
            {name: 'handleNode', hidden: true},
            {name: 'repairUser', hidden: true},
            {name: 'isPrevented', hidden: true}
        ]
        // ,
        // gridComplete: function () {
        //     // 对于已超期的维修工单行背景渲染为红色
        //     var ids = $('#jqGrid').getDataIDs();
        //     for (var i = 0; i < ids.length; i++) {
        //         var rowData = $('#jqGrid').getRowData(ids[i]);
        //         if (rowData.isPrevented == 1) {
        //             $('#' + ids[i]).find("td").addClass("urgeCss");
        //         }
        //     }
        // }
    });
    //通过shiro隐藏列
    var lableShiro = $("#shiroLable").val();
    if ("wx" != lableShiro) {//
        $("#jqGrid").setGridParam().hideCol("records");
        $("#jqGrid").setGridParam().hideCol("ChgRecords");
        $("#jqGrid").setGridParam().hideCol("8dRec");
        $("#jqGrid").setGridWidth($(window).width() * 0.84);
    }
    // 加载设备组织树数据
    vm.getTreeList();
    /*如果repaircode存在在执行一次查询*/
    if (repairCode) {
        setTimeout(function (res) {
            vm.reload();
        }, 30)
    }
});
//人员树
var userSetting = {
    data: {
        simpleData: {
            enable: true,
            idKey: "deptId",
            pIdKey: "parentId",
            rootPId: -1
        },
        key: {
            url: "nourl"
        }
    }
};
var userZtree;

//设备组织树
var deptSetting = {
    data: {
        simpleData: {
            enable: true,
            idKey: "deptId",
            pIdKey: "parentId",
            rootPId: -1
        },
        key: {
            url: "nourl",
            name: "complexName"
        }
    },
    callback: {
        beforeCheck: true,
        beforeClick: outTreeCheck
    }
};

function outTreeCheck(e, treeObj, treeNode) {
    vm.q.devDeptId = treeObj.deptId;
    vm.query();
}

var vm = new Vue({
    el: '#rrapp',
    data: {
        devMaintenWork: {
            isSure: '',
            approvalId: '',
            devStatus: '',
            uploadDate: '',
            faultCon: '',
            faultType: '',
            faultCode: '',
            uploadName: '',
            uploadId: '',
            devId: '',
            devName: '',
            devCode: '',
            repairCode: '',
            workshopId: '',
            workshopName: '',
            id: '',
            existent: '1',
            delFlag: '',
            repairUser: '',
            approvalDate: '',
            imgUrl: '',
            devProceNo: '',
            devProceName: '',
            devProductName: '',
            devProductCode: ''
        },
        planPerson: [], // 辅修人员列表
        updateImgList: [],//上传图片列表
        visibleImg: false,//控制图片预览
        showList: true,
        isDisabled: false,
        play: false,
        deviceInfoList: {},
        defaultList: [],
        imgName: '',
        visible: false,
        title: null,
        isHas: true,
        devReportUrge: {},
        repairUserList: {},
        /*     devMaintenWork: {
                 id: '',
                 repairUser: '',
                 existent: 0,
             },*/
        ruleValidate: {
            devName: [
                {required: true, message: '设备名称不能为空！', trigger: 'change'}
            ],
            devCode: [
                {required: true, message: '设备编号不能为空！', trigger: 'change'}
            ],
            alarmCategoryId: [
                {required: true, message: '报警分类必选！', trigger: 'change'}
            ]
        },
        repairStartRange: [], // 维修开始查询时间区间
        q: {
            repairCode: '', // 维修工单号
            devDeptId: '', // 设备组织ID
            devCode: '',// 设备编码
            name: '',
            beginTime: '',
            endTime: '',
        },
        user: {
            deptId: '',
            deptName: '',
            userId: '',
            userName: ''
        },
        devStatusArray: enumsToList("DEV_STATUS"),
        isSureArrays: enumsToList("IS_SURE"),
        reportPersonList: [],// 上报人员选择列表
        assistPersonId: '', // 协助人员ID
        auxiliary: [] // 辅修人员列表
    },
    methods: {
        handleRepairStartRangeChange(dateVal, dateType) {
            this.q.beginTime = dateVal[0];
            this.q.endTime = dateVal[1];
        },
        getTreeList: function () {
            Ajax.request({
                url: '../sys/user/treeDeptBySCX',
                async: false,
                successCallback: function (r) {
                    vm.treeList = r.list;
                    deptZtree = $.fn.zTree.init($("#storeTree"), deptSetting, vm.treeList);
                    // 默认展开工厂一级
                    deptZtree.expandNode(deptZtree.getNodeByParam("deptId", '01', null));
                }
            });
        },
        query: function () {
            vm.reload();
        },
        details: function () {
            var id = getSelectedRow("#jqGrid");
            var record = getSelectedRowData("#jqGrid");
            if (id == null) {
                return;
            }
            openWindow({
                type: 2,
                title: '<i class="fa fa-bars"></i> 维修工单详情',
                content: '../device/devmaintenworkview.html?Id=' + id
            });
        },
        report: function () {
            this.assistPersonId = '';
            var id = getSelectedRow("#jqGrid");
            if (id == null) {
                return;
            }
            var ticket = getSelectedRowData('#jqGrid');
            if (ticket.devStatus != '3') {
                alert('只有处于[维修中]状态的工单才可以申请上一级协助！');
                return;
            }
            let winTitle = '';
            if (ticket.handleNode == '1') {
                winTitle = '请选择车间协助人员';
            } else if (ticket.handleNode == '2') {
                winTitle = '请选择制造处协助人员';
            } else {
                alert('当前工单制造处协助处理中，已达最高级！');
                return;
            }
            let _this = this;
            Ajax.request({
                url: '../devmaintenwork/assistPersonList',
                type: 'POST',
                params: {"id": id},
                async: false,
                successCallback: function (r) {
                    _this.reportPersonList = r.assistPersonList;
                    openWindow({
                        title: winTitle,
                        area: ['400px', '200px'],
                        content: jQuery("#reportPersonList"),
                        btn: ['确定', '取消'],
                        btn1: function (index) {
                            Ajax.request({
                                url: '../devmaintenwork/report',
                                type: 'POST',
                                params: {'id': id, 'assistPersonId': _this.assistPersonId},
                                async: false,
                                successCallback: function (r) {
                                    alert('操作成功', function (index) {
                                        vm.reload();
                                    });
                                }
                            });
                            layer.close(index);
                        }
                    });
                }
            });
        },
        saveOrUpdate: function (event) {
            var url;
            if (vm.devMaintenWork.id == (null || '')) {
                url = "../devmaintenwork/save";
            } else {
                url = "../devmaintenwork/update";
            }
            Ajax.request({
                url: url,
                params: JSON.stringify(vm.devMaintenWork),
                type: "POST",
                contentType: "application/json",
                successCallback: function (r) {
                    alert('操作成功', function (index) {
                        vm.reload();
                    });
                }
            });
        },
        del: function (event) {
            var ids = getSelectedRows("#jqGrid");
            if (ids == null) {
                return;
            }
            confirm('确定要删除选中的记录？', function () {
                Ajax.request({
                    url: "../devmaintenwork/delete",
                    params: JSON.stringify(ids),
                    type: "POST",
                    contentType: "application/json",
                    successCallback: function () {
                        alert('操作成功', function (index) {
                            vm.reload();
                        });
                    }
                });
            });
        },

        getInfo: function (id) {
            Ajax.request({
                url: "../devmaintenwork/info/" + id,
                async: false,
                successCallback: function (r) {
                    vm.devMaintenWork = r.devMaintenWork;
                    var url = vm.devMaintenWork.imgUrl;
                    if (url != null) {
                        var reg = /,$/gi;
                        url = url.replace(reg, "");
                        var res = url.split(',');
                        for (var i = 0; i < res.length; i++) {
                            var url = res[i];
                            var name = url.substring(url.lastIndexOf("/") + 1);
                            vm.updateImgList.push({'name': name, 'url': url});
                        }
                    }
                }
            });
        },
        getAsyncInfo: function (id) {
            Ajax.request({
                url: "../devmaintenwork/info/" + id,
                async: false,
                successCallback: function (r) {
                    vm.devMaintenWork = r.devMaintenWork;
                }
            });
        },
        reload: function (event) {
            vm.showList = true;
            // 清空postData缓存数据
            var postData = $("#jqGrid").jqGrid("getGridParam", "postData");
            $.each(postData, function (k, v) {
                delete postData[k];
            });
            var page = $("#jqGrid").jqGrid('getGridParam', 'page');
            // 构建查询参数
            var param = {};
            if (vm.q.beginTime) {
                param.beginTime = gmt2DateStr(vm.q.beginTime);
            }
            if (vm.q.endTime) {
                param.endTime = gmt2DateStr(vm.q.endTime);
            }
            if (vm.q.name) {
                param.devName = vm.q.name;
            }
            if (vm.q.devCode) {
                param.devCode = vm.q.devCode;
            }
            if (vm.q.devDeptId) {
                param.devDeptId = vm.q.devDeptId;
            }
            if (vm.q.repairCode) {
                param.repairCode = vm.q.repairCode;
            }
            $("#jqGrid").jqGrid('setGridParam', {
                search: true,
                postData: param,
                page: page
            }).trigger("reloadGrid", [{page: 1}]);
            vm.handleReset('formValidate');
        },
        //数据导出
        exportData: function () {
            var queryStringArray = [];
            if (vm.q.beginTime) {
                queryStringArray.push('beginTime=' + gmt2DateStr(vm.q.beginTime));
            }
            if (vm.q.endTime) {
                queryStringArray.push('endTime=' + gmt2DateStr(vm.q.endTime));
            }
            if (vm.q.name) {
                queryStringArray.push('devName=' + vm.q.name);
            }
            if (vm.q.devCode) {
                queryStringArray.push('devCode=' + vm.q.devCode);
            }
            if (vm.q.devDeptId) {
                queryStringArray.push('devDeptId=' + vm.q.devDeptId);
            }
            if (vm.q.repairCode) {
                queryStringArray.push('repairCode=' + vm.q.repairCode);
            }
            var queryString = '';
            if (queryStringArray.length > 0) {
                queryString = '?' + queryStringArray.join('&');
            }
            window.open(encodeURI('../devmaintenwork/export' + queryString));
        },
        reloadSearch: function () {
            vm.q = {
                devDeptId: '', // 设备组织ID,一般为车间、产线或工序ID
                name: '',
                devCode: '',
                beginTime: '',
                endTime: '',
                repairCode: ''
            };
            this.repairStartRange = [];
            // 取消选中
            deptZtree.cancelSelectedNode();
            vm.reload();
        },
        handleSubmit: function (name) {
            handleSubmitValidate(this, name, function () {
                vm.saveOrUpdate()
            });
        },
        handleReset: function (name) {
            vm.updateImgList = [];//清空图片
        },
        fixedRecord: function (devId) {//通过id查询维修记录
            openWindow({
                type: 2,
                title: '<i class="fa fa-bars"></i> 记录信息',
                content: '../device/devrepairList.html?devId=' + devId
            })
        },
        changeRecord: function (id) {//通过id查询变更记录
            //查询换件记录
            openWindow({
                type: 2,
                title: '<i class="fa fa-bars"></i> 换件记录',
                content: '../device/changeList.html?workId=' + id
            })
        },
        Record8D: function (devCode) {//通过id查询8d报告
            // alert(id+"............Record8D");devCode
            openWindow({
                type: 2,
                title: '<i class="fa fa-bars"></i> 8d报告',
                content: '../device/follow8dlist.html?devCode=' + devCode
            })
        },
        getDept: function () {
            //加载部门树
            Ajax.request({
                url: '../sys/user/treeDept',
                async: true,
                successCallback: function (r) {
                    userZtree = $.fn.zTree.init($("#deptTree"), userSetting, r.list);
                    var node = userZtree.getNodeByParam("deptId", vm.user.deptId);
                    if (node != null) {
                        ztree.selectNode(node);
                        vm.user.deptName = node.name;
                    }
                }
            });
        },
        getByDevCode: function (id) {
            if (!id) {
                return;
            }
            Ajax.request({
                url: "../deviceinfo/info/" + id,
                type: 'POST',
                successCallback: function (r) {
                    var deviceInfo = r.deviceInfo;
                    vm.devMaintenWork.devId = deviceInfo.id;
                    vm.devMaintenWork.devCode = deviceInfo.devCode;
                    vm.devMaintenWork.devName = deviceInfo.devName;
                }
            });
        },
        // 维修完成
        completeRepair: function () {
            let ticketId = getSelectedRow('#jqGrid');
            if (!ticketId) {
                return;
            }
            let ticket = getSelectedRowData('#jqGrid');
            if (ticket.devStatus != '3') {
                alert('只有处于维修中的工单才可以确认完成！');
                return;
            }
            Ajax.request({
                url: '../devmaintenwork/completeRepair',
                params: {"id": ticketId},
                type: 'POST',
                async: false,
                successCallback: function (r) {
                    if (r.over > 0) {
                        alert("操作成功");
                    } else {
                        alert("当前工单已结束，无需重复完成！");
                    }
                    vm.reload();
                }
            });
        },
        handleView: function (url) {
            vm.imgName = url;
            vm.visibleImg = true;
        },
        handleRemove: function (file) {
            var delUrl = file.url + ','
            vm.updateImgList.splice(vm.updateImgList.indexOf(file), 1);
        },
        handleSuccess: function (res, file) {
            this.$Loading.finish();
            iview.Message.success('文件上传成功');
            urlJson += file.response.url + ',';
            vm.updateImgList.push({
                'name': file.response.name,
                'url': file.response.url,
            });
            vm.devMaintenWork.imgUrl = urlJson;
        },
        // 完善维修记录
        addRepairRecord: function () {
            let ticketId = getSelectedRow("#jqGrid");
            if (ticketId == null) {
                return;
            }
            let ticket = getSelectedRowData("#jqGrid");
            openWindow({
                type: 2,
                title: '<i class="fa fa-bars"></i> 完善维修记录',
                content: '../device/perfectRepairRecord.html?id=' + ticketId,//+'&workId'+date.id
                btn: ['确定', '取消'],
                btn1: function (index) {
                    var iframeWin = window["layui-layer-iframe" + index];
                    var devRepairRecord = iframeWin.getDateform();
                    if (devRepairRecord.repairStartDate) {
                        devRepairRecord.repairStartDate = gmt2DateTimeStr(devRepairRecord.repairStartDate);
                    }
                    if (devRepairRecord.repairEndDate) {
                        devRepairRecord.repairEndDate = gmt2DateTimeStr(devRepairRecord.repairEndDate);
                    }
                    if (!devRepairRecord.faultCategoryId) {
                        alert('故障分类必选！');
                        return;
                    }
                    if (!devRepairRecord.recordDescr) {
                        alert('故障描述必填！');
                        return;
                    }
                    if (!devRepairRecord.reason) {
                        alert('原因分析必填！');
                        return;
                    }
                    if (!devRepairRecord.solution) {
                        alert('解决方法必填！');
                        return;
                    }
                    if (devRepairRecord.preventMeasureList.length > 0) {
                        for (let i = 0; i < devRepairRecord.preventMeasureList.length; i++) {
                            devRepairRecord.preventMeasureList[i].startDate = (gmt2DateTimeStr(devRepairRecord.preventMeasureList[i].startDate)).substring(0, 16)
                            devRepairRecord.preventMeasureList[i].endDate = (gmt2DateTimeStr(devRepairRecord.preventMeasureList[i].endDate)).substring(0, 16)
                        }
                    }
                    if (!devRepairRecord.attachment) {
                        devRepairRecord.attachment = '';
                    }
                    //当前维修时长已超过8小时，是否确认正确输入维修开始时间和维修结束时间？
                    let starDate = new Date(devRepairRecord.repairStartDate).getTime();
                    let endTime = new Date( devRepairRecord.repairEndDate).getTime();
                    let eight = 8*60*60*1000;
                    if((endTime-starDate)>eight){
                        confirm('当前维修时长已超过8小时，是否确认输入正确的维修开始和维修结束时间？',function (){
                            Ajax.request({
                                url: "../devmaintenrepair/save",
                                params: JSON.stringify(devRepairRecord),
                                type: "POST",
                                contentType: "application/json",
                                successCallback: function (r) {
                                    if (r.code == 0) {
                                        alert('操作成功', function (index) {
                                            vm.reload();
                                        });
                                        layer.close(index);
                                    }
                                }
                            });
                        })
                    }else{
                        // 获取请求URL
                        Ajax.request({
                            url: "../devmaintenrepair/save",
                            params: JSON.stringify(devRepairRecord),
                            type: "POST",
                            contentType: "application/json",
                            successCallback: function (r) {
                                if (r.code == 0) {
                                    alert('操作成功', function (index) {
                                        vm.reload();
                                    });
                                    layer.close(index);
                                }
                            }
                        });
                    }
                }
            });
        },
        urge: function () {
            var id = getSelectedRow("#jqGrid");
            if (id == null) {
                return;
            }
            // 校验工单是否已催办
            var ticket = getSelectedRowData("#jqGrid");
            if (ticket.urgeStatus == 1) {
                layer.alert('催办处理中，请耐心等待！', {icon: 5});
                return;
            }
            //判断是否进行催办,如存在催办   修改催办状态
            vm.devReportUrge.repairNo = id;
            //插入记录
            confirm('确定要催办选中的记录？', function () {
                Ajax.request({
                    url: "../devmaintenwork/urgeSave",
                    params: JSON.stringify(vm.devReportUrge),
                    type: "POST",
                    contentType: "application/json",
                    successCallback: function (r) {
                        alert('操作成功', function (index) {
                            vm.reload();
                        });
                    }
                });
            });
        },
        //维修人员确定维修工单
        orderSure: function () {
            var ticketId = getSelectedRow("#jqGrid");
            if (ticketId == null) {
                return;
            }
            //判断当前人员是否已经确定该订单
            Ajax.request({
                url: '../devmaintenwork/orderSure',
                type: 'POST',
                params: {'id': ticketId},
                async: false,
                successCallback: function (r) {
                    if (r.isHas == false) {
                        alert("当前任务已确定");
                    } else {
                        alert("操作成功", function (index) {
                            vm.reload();
                        });
                    }
                }
            })
        },
        //添加异常
        exception: function () {
            var ids = getSelectedRows("#jqGrid");
            if (ids == null) {
                return;
            }
            var id = ids[0];
            var ani = getauxiliary(id);
            var date = getSelectedRowData("#jqGrid");
            if (ani > 0) {
                alert("该任务为辅助任务,无法操作")
            } else {
                openWindow({
                    type: 2,
                    title: '<i class="fa fa-bars"></i> 异常记录',
                    area: ['700px', '430px'],
                    content: '../device/addExcepRecord.html?devCode=' + date.devCode + '&id=' + ids[0],
                    btn: ['确定', '取消'],
                    btn1: function (index) {
                        var iframeWin = window["layui-layer-iframe" + index];
                        var res = iframeWin.getExcept();
                        res.devCode = date.devCode;
                        res.devName = date.devName;
                        res.workshopId = date.workshopId;
                        res.exType = 1;
                        if (res != null) {
                            Ajax.request({
                                url: "../exceprecord/save",
                                params: JSON.stringify(res),
                                type: "POST",
                                contentType: "application/json",
                                successCallback: function (r) {
                                    alert('操作成功', function (index) {
                                        vm.reload();
                                    });
                                }
                            });
                        }
                        layer.close(index);
                    }
                });
            }
        },
        //是否存在故障库
        showEx: function () {
            console.log(vm.devMaintenWork.existent);
        },
        //显示故障库类别
        faultTable: function () {
            openWindow({
                type: 2,
                title: '<i class="fa fa-file-text-o"></i> 选择故障',
                content: '../device/faultInfoSelect.html',
                btn: ['确定', '取消'],
                btn1: function (index) {
                    var iframeWin = window["layui-layer-iframe" + index];
                    var res = iframeWin.getFaultInfo();
                    if (!res) {
                        iview.Message.error("请选择一条记录");
                    } else {
                        layer.close(index);
                    }
                }
            })
        },
        //添加8d报告
        // eDrep: function () {
        //     var date = getSelectedRowData("#jqGrid");
        //     var devCode = date.devCode;
        //     // var devName = date.devName;
        //     // var workshopId = date.workshopId;
        //     openWindow({
        //         type: 2,
        //         title: '<i class="fa fa-file-text-o"></i> 8D报告',
        //         content: '../device/add8D.html?devCode=' + devCode,
        //         btn: ['确定', '取消'],
        //         btn1: function (index) {
        //             var iframeWin = window["layui-layer-iframe" + index];
        //             var res = iframeWin.getDateform();
        //             res.devName = date.devName;
        //             res.workshopId = date.workshopId;
        //             res.happenDate = date.uploadDate;
        //             if (!res) {
        //                 iview.Message.error("请选择一条记录");
        //             } else {
        //                 vm.add8Drec(res);
        //                 layer.close(index);
        //             }
        //         }
        //     });
        // },
        //针对选择辅助人员显示
        carryClick: function (value) {
            for (var size = 0; size < vm.planPerson.length; size++) {
                if (vm.planPerson[size].userId === value) {
                    vm.planPerson = [];
                    $.ajax({
                        url: '../maintainplan/queryKeppDept',
                        type: 'GET',
                        success: function (index) {
                            var deptList = index.deptList;
                            if (deptList.length > 1) {
                                for (var dept in deptList) {
                                    if (deptList.hasOwnProperty(dept)) {
                                        var data = deptList[dept];
                                        if (data.USER_ID != value) {
                                            var userId = data.USER_ID;
                                            var userName = data.USER_NAME;
                                            vm.planPerson.push({
                                                'userId': userId,
                                                'userName': userName
                                            });
                                        }
                                    }
                                }
                            }
                        }
                    });
                }
            }
        },
        //新增8d记录
        add8Drec: function (res) {
            var ids = getSelectedRows("#jqGrid");
            if (ids == null) {
                return;
            }
            if (res.closeDate) {
                res.closeDate = this.GMT2Str(res.closeDate);
            }
            if (res.happenDate) {
                res.happenDate = this.GMT2Str(res.happenDate);
            }
            Ajax.request({
                url: "../follow8drecord/save8D",
                params: JSON.stringify(res),
                type: "POST",
                contentType: "application/json",
                successCallback: function (r) {
                    if (r.i > 0) {//更新维修工单
                        Ajax.request({
                            url: '../devmaintenwork/update8d',
                            type: 'POST',
                            params: {"id": ids[0]},
                            async: false,
                            successCallback: function (r) {
                                alert('操作成功', function (index) {
                                    vm.reload();
                                });
                            }
                        })
                    }
                }
            });
        },
        GMT2Str: function (gmt) {
            let dateTime = new Date(gmt)
            let year = dateTime.getFullYear()
            let month = dateTime.getMonth() + 1
            let date = dateTime.getDate()
            let hour = dateTime.getHours()
            let minute = dateTime.getMinutes()
            let second = dateTime.getSeconds()
            return year + '-' + this.addZero(month) + '-' + this.addZero(date) + ' ' + this.addZero(hour) + ':' + this.addZero(minute) + ':' + this.addZero(second);
        },
        addZero(v) {
            return v < 10 ? '0' + v : v
        },
        handleBeforeUpload: function () {
            this.$refs.uploadFile.clearFiles();
            this.$Loading.start();
        },
        handleFormatError: function (file) {
            this.$Notice.warning({
                title: '文件格式不正确',
                desc: '文件 ' + file.name + ' 格式不正确，请上传.xls或.xlsx的文件。'
            });
        },
        handleSuccess: function (res, file) {
            if (res.code == 0) {
                this.$Loading.finish();
                iview.Message.success('文件上传成功');
                alert(res.msg, function (index) {
                    vm.reload();
                });
            } else {
                this.$Loading.error();
                this.$Notice.error({
                    title: '导入失败',
                    desc: res.msg
                })
            }
        },
        handleError2: function (err, file) {
            alert('导入失败');
        },
    }
});

function getauxiliary(id) {
    var i;
    Ajax.request({
        url: '../devmaintenwork/Auxiliary',
        type: 'POST',
        params: {"id": id},
        async: false,
        successCallback: function (r) {
            i = r.i
        }
    })
    return i;
}
